/*
     构建有参类
 */
public class Student01 {
    private String name;
    private int age;

    /*
        public void setName(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setAge(int age) {
            if (age > 0 && age <= 120) {
                this.age = age;
            } else {
                System.out.println("请输入正确的数字!");
            }
        }

        public int getAge() {
            return age;
        }
    */
    public Student01(String name, int age) {
        this.name = name;
        if (age > 0 && age <= 120) {
            this.age = age;
        } else {
            System.out.println("请输入正确的数字!");
        }
    }

    public void show() {
        System.out.println(name + "  " + age);
    }
}
